package com.it135.citytraffic.controller;

import com.it135.citytraffic.pojo.result.Result;
import com.it135.citytraffic.service.VisitsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/visits")
public class VisitsController {
    @Autowired
    VisitsService visitsService;

    @CrossOrigin
    @GetMapping
    public Result<Integer> getVisits() {
        int visits = visitsService.getVisitsCount();
        return Result.success(visits);
    }
}
